package com.me.dao.impl;

import com.me.dao.ISpecialityDao;
import com.me.domain.Speciality;
import com.me.util.DBHelper;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class SpecialityDao implements ISpecialityDao {
    @Override
    public List<Speciality> getAll() {
        try {
            QueryRunner runner = new QueryRunner(DBHelper.getDatasource());
            String sql = "select * from speciality";
            return runner.query(sql,new BeanListHandler<Speciality>(Speciality.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
